﻿using HelloASPNET.TruyXuatDuLieu;
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HelloASPNET.Test
{
  public partial class DanhSach : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        GridView1.DataSource = TienIchSQL.ChayLenhSelectDuLieu("Select * from NguoiDung");
        GridView1.DataBind();
      }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
      string str = "";
      foreach (GridViewRow row in GridView1.Rows)
      {
        TextBox txt = row.FindControl("txtSoLuong") as TextBox;        
        if (txt != null)
          str += string.Format("{0} -> {1}; ", row.DataItem, txt.Text);
      }
      Response.Write(str + "<br/>");

      TienIch.TienIchWeb.MsgBox(this,"Ban vua bam nut");
    }

    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {      
      string key = "Keys: ";
      foreach (object k in e.Keys)
        key += k.ToString() + ";";
      string value = "Values: ";
      foreach (object v in e.Values)
        value += v.ToString() + ";";
      Response.Write(key + "<br/>");
      Response.Write(value+ "<br/>");
      this.ClientScript.RegisterClientScriptBlock(typeof(Page), "message", "");
    }

  }
}